package com.kjzy;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
//import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

//使用@EnableEurekaClient注解，标记当前应用为Eureka客户端，
// 会自动向配置的注册中心进行服务注册
//@EnableEurekaClient
@SpringBootApplication
@MapperScan("com.kjzy.dao")
//开启openfeign的功能，指定FeignClient所在包
@EnableFeignClients(basePackages = "com.kjzy.api.client")
public class EurekaConsumerApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaConsumerApplication.class, args);
    }
//RestTemplate是Spring提供的用于访问Rest服务的客户端实例
    @Bean
//    RestTemplate被@LoadBalanced注解后，就具有了负载均衡的能力，
//    也就是在发送HTTP请求后，使用负载均衡机制
    @LoadBalanced
    public RestTemplate restTemplate(){
        return  new RestTemplate();
    }
}
